#include<login.pb.h>
#include<iostream>
#include"mprpc.h"
#include"rpcprovider.h"
#include<string>
#include"logger.h"

class UserService : public login::UserServiceRpc
{
public:
    //模拟注册方法
    void Login(std::string name,std::string pwd)
    {
        std::cout << "doing login" << std::endl;
        std::cout << "name:" << name << std::endl; 
        std::cout << "pwd:" << pwd << std::endl;
    }

    void Login(::google::protobuf::RpcController* controller,
            const ::login::LoginRequest* request,
            ::login::LoginResponse* reponse,
            ::google::protobuf::Closure* done)
    {
        std::string name=request->name();
        std::string pwd=request->pwd();
        Login(name,pwd);
        login::ResultCode* code=reponse->mutable_result();
        code->set_errcode(0);
        code->set_errmesg("");
        reponse->set_success(true);
        
        done->Run();
    }
};




int main(int argc,char** argv)
{
    LOG_INFO("test")

    Mprpc::Init(argc,argv);
    RpcProvider provider;
    provider.NotifyServic(new UserService());
    provider.Run();
    return 0;
}
